varying vec3 u;
varying vec3 n;
uniform sampler2D envMap;

void main(void)
{
   vec3 r = reflect(u, n);
   float m = 2.0 * sqrt(r.x*r.x + r.y*r.y + (r.z + 1.0)*(r.z + 1.0));
   vec2 TexCoord = vec2( r.x/m + 0.5, r.y/m + 0.5);
   gl_FragColor = texture2D (envMap, TexCoord);
}